var win = Titanium.UI.currentWindow;

win.orientationModes = [
	Titanium.UI.PORTRAIT,
	Titanium.UI.LANDSCAPE_LEFT,
	Titanium.UI.LANDSCAPE_RIGHT
]; 

var isAndroid = Ti.Platform.osname == 'android';

if (isAndroid) {
	var showCancel = Ti.UI.createSwitch({
		style : Ti.UI.Android.SWITCH_STYLE_CHECKBOX,
		title: 'Show Cancel Button',
		top : 160
	});
	
	var applyButtons = function() 
	{
		if (showCancel.value) {
			dialog.buttonNames = [ 'Cancel'];
		} else {
			dialog.buttonNames = [];
		}
	};
}
//
// BASIC OPTIONS DIALOG
//

var optionsDialogOpts = {
	options:['Save', 'Cancel'],
	destructive:1,
	cancel:2,
	title:'Save the date and get reminders'
};

if (isAndroid) {
	optionsDialogOpts.selectedIndex = 3;
}

var dialog = Titanium.UI.createOptionDialog(optionsDialogOpts);

// add event listener
dialog.addEventListener('click',function(e)
{
	
	if (isAndroid) {
		if (e.button) {
			label.text += ' button';
		}  else {
			label.text += ' option';
		}
	}
});

if (isAndroid) {
	dialog.androidView = null;
	applyButtons();
}
dialog.show();

if (isAndroid) {
	win.add(showCancel);
}